﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Windows.Automation.Peers;
using System.Windows.Automation.Provider;

namespace Type2Diabetes
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            
        }
        dbFunctions dbfunc = new dbFunctions();
        private void checkBox1_Checked(object sender, RoutedEventArgs e)
        {

        }

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            bool flag = false;
            try
            {
                MessageBox.Show(dbfunc.get_person_info().ToString());
            }
            catch (Exception excep)
            {
                MessageBox.Show("Welcome New User, please enter your details");
                flag = true;
            }
            if (!flag)
            {
                Uri doctor = new Uri("/Pages/Page3_Function List.xaml", UriKind.Relative);
                NavigationService.Navigate(doctor);
            }
        }


        private void PhoneApplicationPage_Loaded_1(object sender, RoutedEventArgs e)
        {

        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            string gender;
            if (male.IsChecked.Value)
            {
                gender = "male";
            }
            else gender = "female";
            float type;
            if (Type1.IsChecked.Value)
            {
                type = 1;
            }
            else type = 2;
            
            dbfunc.insert_into_person(1, FName.Text, LNameBox.Text, gender, 
                DateTime.Now.Date, float.Parse(height.Text), 
                float.Parse(weight.Text), float.Parse(ideaalwt.Text), 
                DateTime.Now.Date, type);

        }
    }
}